﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;

namespace QLKS
{
    class KetNoi
    {
        private static string strconn = @"Data Source=localhost;Initial Catalog=QLKS;Integrated Security=True;";

        public static string Strconn
        {
            get { return KetNoi.strconn; }
            set { KetNoi.strconn = value; }
        }
        private static SqlConnection conn;

        public static SqlConnection Conn
        {
            get { return KetNoi.conn; }
            set { KetNoi.conn = value; }
        }

        /// <summary>
        /// Kết nối tới CSDL sử dụng chuỗi strconn
        /// </summary>
        public static void ThietLapKetNoi()
        {
            try
            {
                conn = new SqlConnection(strconn);
                conn.Open();
            }
            catch { }
        }

        /// <summary>
        /// Đóng kết nối tới CSDL
        /// </summary>
        public static void NgatKetNoi()
        {
            conn.Close();
        }
    }
}
